import {createAction} from "redux-actions";
import {call, put} from "redux-saga/effects";
import {getDepart} from "../../../utils/RequestUtils";
import {DEPART_EXPAND_ITEM, DEPART_LIST, DEPART_LIST_FETCH} from "../../types";
// 获取科室列表
export const departList = createAction(DEPART_LIST, (data: []) => {
    return {data};
});


export const departExpandItem = createAction(DEPART_EXPAND_ITEM, (id: string) => {
    return {id};
});

export const departListFetch = createAction(DEPART_LIST_FETCH, (params: object) => {
    return {...params};
});


export function* requestDepartList(params: object) {
    yield put(departList([]));
    const fetchedData = yield call(getDepart, params);
    yield put(departList(fetchedData.data));
}